package com.lq.ecoldchain.binding

import android.arch.lifecycle.MutableLiveData
import android.databinding.BindingAdapter
import android.widget.ImageView
import com.lq.ecoldchain.R

/*
*2019/1/10 0010  15:29
*function by lq
*/
@BindingAdapter("offIcon")
fun setoffIconResource(view:ImageView,isTrue: MutableLiveData<Boolean>) {
    if(isTrue.value == false){
        view.setImageResource(R.drawable.no_icon)
    }else{
        view.setImageResource(R.drawable.off_icon)
    }
    view.setOnClickListener {
        if(isTrue.value==true){
            view.setImageResource(R.drawable.no_icon)
            isTrue.value = false
        }else{
            view.setImageResource(R.drawable.off_icon)
            isTrue.value = true
        }
    }
}